package com.chixing.controller;


import com.chixing.entity.Coupon;
import com.chixing.service.ICouponService;
import com.chixing.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author smith
 * @since 2025-05-21
 */
//@Controller
@RequestMapping("/coupon")
@RestController
public class CouponController {
    @Autowired
    private ICouponService couponService ;
    //根据id查找
    @GetMapping("{couponId}")
    public Result getById(@PathVariable("couponId") Integer couponId) {
        return couponService.getById(couponId);
    }
    // 查询所有
    // http://localhost:8080/kfc/coupon
    @GetMapping
    public Result getAll(){
        return couponService.getAll();
    }
    //根据type查询
    @GetMapping("/type/{couponType}")
    public Result getByTypeId(@PathVariable String couponType){
        Result result = couponService.getByTypeId(couponType);
        return  result;
    }
    //得到所有type
    @GetMapping("/type")
    public Result getAllType() {
        return couponService.getAllType();
    }
    //更新
    @PutMapping
    public Result update(@RequestBody Coupon coupon){
        Result result = couponService.update(coupon);
        return result;
    }
    /*
    //领取的coupon
    @GetMapping("/my")
    public Result mycoupon(){
        Result result = couponService.mycoupon();
        return  result;
    }
     */
                
}

